<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
	<a href="javascript:$('#win_photo_album').dialog('close');" class="window-close"></a>
	<div class="tc_top fl"><h2>相册</h2></div>
	<div class="tc_add fl form">
		<div class="tc-said">
	   		<h2 class="font_s">相册名称</h2>
			<input id="win_album_albumName" value="${album.albumName}" class="easyui-validatebox ipt_txt" data-options="required: true, validType: 'length[0, 30]'"/>
	   	</div>
		<div class="tc-said">
	   		<h2 class="font_s">相册描述</h2>
			<textarea id="win_album_albumDescr">${album.albumDescr}</textarea>
	   	</div>
		<a class="easyui-linkbutton tg-btn" href="javascript:void(0);" onclick="tendog.win.albumAction.save(this)">确认保存</a>
	</div>
<script type="text/javascript">
	tendog.win.albumAction={
		save:function() {
			var album = {
						"album.id":"${param['id']}",
						"album.albumName":$("#win_album_albumName").val(),
						"album.albumDescr":$("#win_album_albumDescr").val()
					};
			$.post('${ctx}/photo/saveAlbum.do', album, function(res) {
				if(res.code==1) {
					if("${param['id']}" == "") {
						//tendog.win.albumAction.createAlbumHtml(res.attributes.album);
						tools.href("${ctx}/photo/photos.do?id=" + res.attributes.album.id);
					} else {
						$("li[albumId='${param['id']}'] span.photo_name").html($("#win_album_albumName").val());
						$('#win_photo_album').dialog('close');
					}
				} else {
					msg.error(res.msg);
				}
			},"json");
		},
		createAlbumHtml:function(album) {
			var $li = $("<li></li>").attr("albumId", album.id);
			var $p = $("<p></p>").addClass("photo_bg");
			var $img = $("<img width='170' height='110'/>").attr("src", "${ctx}/tools/download.do?dir=PHOTO&fileName=" + album.albumCoverPath?album.albumCoverPath:"");
			$li.append($p.append($img));
			var $titleP = $("<p class='p_font'></p>")
			.append("<span class='photo_name'>" + album.albumName + "</span>")
			.append("<br/>")
			.append($("<a>修改名称</a>").attr("href", "javascript:tendog.win.photoAlbum('"+album.id+"')"))
			.append("&nbsp;")
			.append($("<a>删除</a>").attr("href", "javascript:deleteAlbum('" + album.id + "')"));
			$li.append($titleP);
			$("#album_append_li").before($li);
		}
	};
</script>
</body>
</html>